/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;
import java.util.Random;
/**
 *
 * @author frances
 */
public class CAPTCHAGenerator {
    public int generateCAPTCHA(){
//    log("Generating random integers in the range 1..10.");
    
    int START = 1000;
    int END = 9999;
    Random random = new Random();
   
    int randomNum = showRandomInteger(START, END, random);
    
    return randomNum;
//    log("Done.");
  }
    
    private int showRandomInteger(int aStart, int aEnd, Random aRandom){
    if ( aStart > aEnd ) {
      throw new IllegalArgumentException("Start cannot exceed End.");
    }
    //get the range, casting to long to avoid overflow problems
    long range = (long)aEnd - (long)aStart + 1;
    // compute a fraction of the range, 0 <= frac < range
    long fraction = (long)(range * aRandom.nextDouble());
    int randomNumber =  (int)(fraction + aStart);    
    
    return randomNumber;
//    log("Generated : " + randomNumber);
  }
}
